package com.niit.hjw.avgupricebycomm;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;


public class AvgUPriceByCommDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();
        // 1.声明Job对象
        Job job = Job.getInstance(conf);
        // 2.指定当前job的Mapper和Reducer
        job.setMapperClass(AvgUPriceByCommMapper.class);
        job.setReducerClass(AvgUPriceByCommReducer.class);
        // 3.指定Mapper输出的key和value的类型 (内部要用)
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        // 4.指定Reducer输出结果的key和value的类型 (内部要用)
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);
        // 5.指定输入和输出路径
        FileInputFormat.addInputPath(job, new Path("input/anjuke.txt"));
        FileOutputFormat.setOutputPath(job, new Path("output/hjw_out/avgupricebycomm"));
        // 6.提交任务
        job.waitForCompletion(true);
    }
}
